package com.telecom.cms.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.telecom.cms.util.*;

import com.telecom.cms.dto.*;
public class SEG_APP_SUBJECT_DEFDAO {

	private static final String SQL_FINDALL = "select * from "+Constant.SEG_APP_SUBJECT_DEF;

	private Connection conn = null;

	public SEG_APP_SUBJECT_DEFDAO(Connection con) {

		this.conn = con;

	}

	public List findAll() {
		PreparedStatement ps = null;
		ResultSet rs = null;
		List list = new ArrayList();
		try {
			ps = conn.prepareStatement(SQL_FINDALL);
			rs = ps.executeQuery();
			while (rs.next()) {
				SEG_APP_SUBJECT_DEFDTO dto = new SEG_APP_SUBJECT_DEFDTO();
				dto.setAPP_SUBJECT_ID(rs.getInt(1));
				dto.setAPP_SUBJECT_NAME(rs.getString(2));
				list.add(dto);
			}

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				
				if(rs !=null){
					
					rs.close();
				}
				if (ps != null)
				{	ps.close();}

			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return list;
	}

}
